(function () {
    $('#query').on('click', function () {
        var paName = $('#paName').val();
        var paPassword = $('#paPassword').val();
        if (!/^(\w|[\u2E80-\u9FFF]+){1,16}$/.test(paName)){
            layer.tips('卷名不正确！', '#paName', {tips:[1,'rgba(0,0,0,0.5)'], time:3000})
            return;
        }
        if (!/^\w{2,16}$/.test(paPassword)){
            layer.tips('密码不正确！', '#paPassword', {tips:[1,'rgba(0,0,0,0.5)'], time:3000})
            return;
        }
        $.ajax({
            url: '/addPaper',
            method: 'post',
            data: {paName: paName, paPassword: paPassword},
            success: function (jsonResult) {
                if (jsonResult.status == 1) {
                    layer.msg('添加成功', {icon: 6}, function () {
                        location.href = '/'
                    })
                }
                else layer.msg('添加失败', {icon: 5})
            },
            error: function () {
                layer.msg('服务器异常！')
            }
        })
    })
})();